//
//  MNDFinanceDetailCell.m
//  minidai
//
//  Created by 谭伟 on 2017/4/19.
//  Copyright © 2017年 迷你金服. All rights reserved.
//
#pragma mark -投资详情cell

#import "MNDFinanceDetailCell.h"
#define kBottomLineWidth [UIScreen mainScreen].bounds.size.width*0.25
@interface MNDFinanceDetailCell()<UICollectionViewDelegate,UICollectionViewDataSource>

@end

@implementation MNDFinanceDetailCell

- (void)awakeFromNib {
    [super awakeFromNib];
    _selectButton = _firstButton;
    _selectButton.selected = YES;
//    UICollectionView *collectionView = [[UICollectionView alloc]init];
//    _collectionView = collectionView;
//    
//    _collectionView.delegate = self;
//    _collectionView.dataSource = self;
    // Initialization code
}

- (IBAction)clickButton:(UIButton *)sender {
    _selectButton.selected = NO;
    _selectButton = sender;
    _selectButton.selected = YES;
    [UIView animateWithDuration:0.25 animations:^{
        self.bottomLineLead.constant = (sender.tag-100)*kBottomLineWidth;
        self.collectionView.contentOffset = CGPointMake(kScreenWidth*(sender.tag-100), 0);
    }];
}


#pragma mark -UICollectionViewDelegate,UICollectionViewDataSource

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    
    return 5;
}

// The cell that is returned must be retrieved from a call to -dequeueReusableCellWithReuseIdentifier:forIndexPath:
- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    collectionView.pagingEnabled = YES;
    
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"DetailCell" forIndexPath:indexPath];
    
    cell.backgroundColor = [UIColor redColor];
    
    //设置cell
    _detailFlowLayout.minimumLineSpacing = 0;
    _detailFlowLayout.minimumInteritemSpacing = 0;
    _detailFlowLayout.itemSize = collectionView.bounds.size;
    _detailFlowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    //搭建cell内部界面
    [self setupCellUIWithCell:cell andIndexPath:indexPath];
    return cell;
}

#pragma mark -搭建cell内部界面

- (void)setupCellUIWithCell:(UICollectionViewCell*)cell andIndexPath:(NSIndexPath *)indexPath {
    NSArray *financeDetailViews = [[NSBundle mainBundle]loadNibNamed:@"MNDFinanceDetailCell" owner:nil options:nil];
    switch (indexPath.row) {
        case 0:
        {
            MNDFinanceDetailCell *collectionView = financeDetailViews[3];
            [cell addSubview:collectionView];
            //            scroview.dir
            [collectionView mas_makeConstraints:^(MASConstraintMaker *make) {
                make.leading.trailing.top.bottom.mas_equalTo(cell);
            }];
        }
            break;
        case 1:
        {
        }
            break;
        case 2:
        {
        }
        case 3:
        {
        }
            break;
            
        default:
            break;
    }

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
